CAUTION: mouse message (clickInText), and returned parameters order (clicked word is now the third parameter, no more the second one) have changed since version 4.2. Don't forget to modify your script accordingly.
Only first param is needed. Order of params 3 to 10 doesn't matter, since the XCMD is able to recognize them.
<WName> is a string giving the windoid name. Many windoids can be opened by using different names.
<Text> is the text that will be displayed in the windoid. It can be litteral or a field descriptor.
Textoid "Test","This is my text"
Textoid "Test",cd fld 1
If you pass a valid field descriptor enclosed in quotes, HyperCard will not interpret it and Textoid will use the full-styled text of that field rather than its text only. If the descriptor is not valid, Textoid will use it as litteral.
Textoid "Test","cd fld 1"
If you want to use the field name, you will use :
Textoid "Test","cd fld" && quote & "Name" & quote
New
If you pass a TEXT/styl resource name from current stack, Textoid will use them as window content. This new feature also allows you to save (by using set ResExport of window <wind> to <resName>) and restore (by using set text of window <wind> to <resName>) full colored text.
<WStyle> is a string defining the window style. Allowed styles are : plain, zoom, roundRect, rect, shadow, windoid, windoidZoom, bigWindoid, bigWindoidZoom, Rinaldoid, RinaldoidZoom (Rinaldoid is the same as windoid, except that it displays the window title). All window styles are floating, except plain, zoom and roundRect. A windoid or Rinaldoid style window will have small scrollbars, while other styles will use standard size. Default is RinaldoidZoom if Rinaldoid WDEF resource is present, windoidZoom if not found.
<Color> is a one or two items string giving the foreground and background color. For each item, allowed values are the standard colors (black, white, blue, red, yellow, cyan, magenta, green), or a three word string corresponding to red, green and blue values (100 5624 28652).
<X,Y[,Z,T]> will be a point or a rect, and will define position and/or size of the windoid. Coordinated are card-relative. If omitted, windoid will appear with standard size at "0,10".
<textWrap> is a boolean to wrap (true) or not (false) the text in the windoid. This param makes also the horizontal scrollBar be invisible (true) or visible (false). Default is true, and horizontal scroll being hidden.
<FName> is a string giving the font that will be used. Default is Geneva.
<FSize> is a string giving the font size that will be used. Default is 9.
<FStyle> is an item(s) string giving the font style(s) that will be used (plain, bold, italic, outline, underline, shadow, condense, extend, grouped). Default is Plain.
<FAlign> is a string giving the text alignment that will be used (left,right, center). Default is left.
Using "!", "?" or "=" as first parameter will return an online help (resp. copyright, syntax and output).
USING
Textoid is stand alone, no linked resource is needed. Meanwhile, this stack contains a WDEF resource that are recognized by the XCMD if present. The WDEF allows to have an enhanced windoid-type window displaying title. So, this resources is optional, and for aesthetic purpose only. If you copy it, its ID can be set to any value but don't change its name. Each window can contain up to 32000 chars.
Hint:
If you use a rect or shadow style window, placing it on a card can simulate a smart double-scroll HyperCard field.
With multiple screens configuration, the windoid will be zoomed on the screen that it lays on.
Textoid offers full text editing with Cut, Copy, Paste and Erase. lockText property allows to lock/unlock the content. When a window is created, its text is locked. Like for a field, the content must be locked to accept mouseDown events (thus HyperText). If unlocked, the insertion point will be set at the clickLoc.
Shortcuts:
• Control-Clic in text allows to move the window
• Command-Click in text locks/unlocks the text (only if UnLockAllowed
property is true).
• Option-Clic in text allows to move text with grabber hand
• Holding ShiftKey makes any scrolling smoother.
• Holding OptionKey while clicking in a scrollBar reverses the scroll
• Command-A selects the whole text (if unlocked)
• Control-Option-P, B, I, U, O, S, C, E, G changes selection style
SelectedChunk property allows to select any part of the text. When using set selectedChunk of window "MyWindow" to "X,Y", the window is brought to the front, the text is automatically unlocked, scrolled to show the insertion point, and you are ready to type in it. You can also get the selectedChunk when the window is closed using :
on closeTextoid Which
get selectedChunk of window Which
put char (item 1 of it) to (item 2 of it) of Text¬
of window Which
end closeTextoid
In order to allow text manipulation by clicking on an HC button, Textoid keep the last selection in a global variable TextoidLastSelection :
Following script will chage current selection to bold :
on mouseUp
global TextoidLastSelection
put item 3 of TextoidLastSelection into WName
set selectedChunk of window WName to ¬
item 1 to 2 of TextoidLastSelection
set textStyle of window WName to "bold"
end mouseUp
Hint:
the insertion point will be placed at the end of the text by using :
set selectedChunk of window MyWindow to 32000
When a Textoid is displayed, font, style, size and even color are accessible using the existing menus. These act exactly like for HyperCard fields : if there is no current selection in the windoid, menus change the global window attributes. Otherwise, only the current selection attributes are changed.
FieldTransfer property (set only) allows to transfer the full-styled text from the windoid to any existing field. Field descriptor must be enclosed in quotes, like the input parameter.
set fieldTransfer of window "Test" to "cd fld 1"
Both scrollBars can now be hidden. In this case, the growBox remains hidden, but is stilll active.
on openTextoid WName,WId
if WName is "MyWindow"
then
set textWrap of window WName to true
set ShowVScroll of window WName to false
end if
end openTextoid
The window content can now be printed by using :
send "print" to window "MyWindow"
MESSAGES
OpenTextoid : sent when a windoid is opened, followed by the windoid name and ID. This allows to define window properties before it is shown, since the message can be trapped using a handler :
on openTextoid WName,WId
if WName is "MyWindow" then...
end openTextoid
CloseTextoid : sent when a windoid is closed, followed by the windoid name and ID. This allows to define window properties before it is shown, since the message can be trapped using a handler :
on closeTextoid WName,WId
if WName is "MyWindow" then...
end closeTextoid
ActivateTextoid : sent for non-floating windows only (plain, zoom, roundRect), when the window is activated. It is followed by the windoid name and ID.
DeActivateTextoid : sent for non-floating windows only (plain, zoom, roundRect), when the window is de-activated. It is followed by the windoid name and ID.
sent when clicking on a word in the locked window, followed by the windoid name and ID, clicked word, start and end char being clicked, font, size, style and color of text.
mouseUpInTextoid is sent only if mouse button is released on the same word that generated the mouseDownInTextoid message.
If the whole sent string (message + params) exceeds 255 chars, then the clicked string will consist of its first 254 chars, followed by character "..." to signify the overflow (the ellipsis character, not three dot characters, hex C9).
on DblClickInTextoid WName,WId,Word,Start,Stop,Font,¬
Size,Style,Color
if WName is "Test1" and Wrd is ...
end DblClickInTextoid
Note:
Font, Size, Style and Color may contain many items if the clicked text has different text attributes.
PROPERTIES
Like any XWindow, Textoid has properties that can be get and set thru HyperTalk. Default values are shown underlined.
properties of window "Textoid" will return an item list of all allowed properties :
• loc : windoid's position according to card (X,Y)
• globalLoc : windoid's position according to screen (X,Y)
• visible : windoid's visibility (true or false)
• id : windoid's id (get only)
• messages : list of messages sent by the windoid
• text : windoid's text (quoted field descriptor gives full style)
• rect : windoid's position and size according to card (X,Y,Z,T)
• globalRect : windoid's position and size according to screen (X,Y,Z,T)
• textFont : current selection's or windoid's font (geneva, times, …)
• textSize : current selection's or windoid's font size (9, 10,…)
• textAlign : windoid's text alignment (left,right,center)
• textStyle : current selection's or windoid's text style (plain,italic,
Free for non-commercial use. Use in commercial software subjected to prior acknowledgement and licensing from the author, reachable at the following network addresses: